export class TableHelper {
    static mapNumToCol(num: number) {
        let res = '';
        let charatorVal =  num % 26;
        let temp = Math.floor(num / 26);
        if(charatorVal == 0) {
            res = String.fromCharCode(26 + 64);
        } else {
            res = String.fromCharCode(charatorVal + 64);
        }
        if(temp > 0 && num != 26) {
            res = TableHelper.mapNumToCol(temp) + res;
        }
        return res;
    }
    static mapColToNum(col: string) {
        let res = 0;
        for(let i = col.length - 1; i >= 0; i--) {
            res += (col[i].charCodeAt(0) - 64) * Math.pow(26, col.length - i - 1);
        }
        return res - 1;
    }
}
